package gui.interfaces;

/**
 * This interface defines the <code>WorkerAction</code> order of operation.</br>
 * The order is:</br>
 * 1. isAllowToRunOperation() - if true we continue to step 2.</br>
 * 2. runOperation() - this will run on a separate thread.</br>
 * 3. operationSucceed() - this will run if runOperation() didn't fail.</br>
 * 3. operationFailed(Exception e) - this will run if runOperation() failed on throwen exception.</br>
 * 4. isAllowToRunCommitOperation() - if true we continue to step 5.</br>
 * 5. runCommitOperation() - this will run on a separate thread.</br>
 * 6. commitOperationSucceed() - this will run if runCommitOperation() didn't fail.</br>
 * 7. commitOperationFailed(Exception e) - this will run if runCommitOperation() failed on throwen exception.</br>
 */
public interface WorkerActionInterface {

	/**
	 * If true we continue to <code>runOperation()</code>
	 */
	public boolean isAllowToRunOperation();

	/**
	 * This will run on a separate thread (not EDT).
	 */
	public void runOperation() throws Exception;
	
	/**
	 * If <code>runOperation()</code> succeed, we continue to this method.
	 */
	public void operationSucceed();
	
	/**
	 * If <code>runOperation()</code> failed, we continue to this method with the throwen exception.
	 */
	public void operationFailed(Exception e);
	
	/**
	 * If true we continue to <code>runCommitOperation()</code>
	 */
	public boolean isAllowToRunCommitOperation();

	/**
	 * This will run on a separate thread (not EDT).
	 */
	public void runCommitOperation() throws Exception;
	
	/**
	 * If <code>runCommitOperation()</code> failed, we continue to this method with the throwen exception.
	 */
	public void commitOperationSucceed();
	
	/**
	 * If <code>runCommitOperation()</code> failed, we continue to this method with the throwen exception.
	 */
	public void commitOperationFailed(Exception e);
}


